<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:hr="http://java.sun.com/jsf/composite/autocomplete">

    <h:body>

        <ui:composition template="/resources/template/template.xhtml">

            <ui:define name="content">

                <h:form >
                    <p:panel >
                        <f:facet name="header" >
                            <h:outputLabel value="Leave Report" />
                        </f:facet>
                        <h:panelGrid columns="2" >
                            <h:outputLabel value="From : " />
                            <p:calendar value="#{hrReportController.fromDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="To : " />
                            <p:calendar value="#{hrReportController.toDate}" pattern="dd MMMM yyyy hh:mm:ss a" />
                            <h:outputLabel value="Department : "/>
                            <hr:department value="#{hrReportController.reportKeyWord.department}"/>
                            <h:outputLabel value="Employee : "/>
                            <hr:completeStaff value="#{hrReportController.reportKeyWord.staff}"/>
                            <h:outputLabel value="Staff Category : "/>
                            <hr:completeStaffCategory value="#{hrReportController.reportKeyWord.staffCategory}"/>
                            <h:outputLabel value="Staff Designation : "/>
                            <hr:completeDesignation value="#{hrReportController.reportKeyWord.designation}"/>
                            <h:outputLabel value="Staff Roster : "/>
                            <hr:completeRoster value="#{hrReportController.reportKeyWord.roster}"/>
                            <h:outputLabel value="Leave Type : "/>
                            <p:selectOneMenu  value="#{hrReportController.reportKeyWord.leaveType}">
                                <f:selectItem itemLabel="Select Day Type : "/>
                                <f:selectItems value="#{enumController.leaveType}"/>
                            </p:selectOneMenu>   
                        </h:panelGrid>

                        <p:commandButton ajax="false" value="Process" action="#{hrReportController.createStaffLeave()}"/>
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tb1" fileName="hr_report_leave"  />
                        </p:commandButton>
                        <p:commandButton value="Print" ajax="false" action="#" >
                            <p:printer target="gpBillPreview" ></p:printer>
                        </p:commandButton>
                        <p:panel id="gpBillPreview"  styleClass="noBorder summeryBorder" >                     
                            <p:dataTable id="tb1" value="#{hrReportController.staffLeaves}" var="ss">
                                <f:facet name="header">
                                    <h:outputLabel value="#{sessionController.loggedUser.institution.name}" /><br></br>
                                    <h:outputLabel value="Leave Report" /><br/>
                                    <h:outputLabel value="  From : "  />
                                    <h:outputLabel  value="#{hrReportController.fromDate}" >
                                        <f:convertDateTime pattern="dd MM yy "/>
                                    </h:outputLabel>
                                    <h:outputLabel/>
                                    <h:outputLabel/>
                                    <h:outputLabel value="  To : "/> 
                                    <h:outputLabel  value="#{hrReportController.toDate}">
                                        <f:convertDateTime pattern="dd MM yy "/>
                                    </h:outputLabel><br/>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.department ne null}" >
                                        <h:outputLabel value="Department : #{hrReportController.reportKeyWord.department.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                    <h:panelGroup rendered="#{hrReportController.reportKeyWord.staff ne null}" >
                                        <h:outputLabel value="Staff : #{hrReportController.reportKeyWord.staff.person.name}"/>
                                        <br/>
                                    </h:panelGroup>
                                </f:facet>

                                <p:column headerText="Form No">
                                    #{ss.form.code}
                                </p:column>
                                <p:column headerText="Emp No">
                                    #{ss.staff.code}
                                </p:column>
                                <p:column headerText="Emp Name">
                                    #{ss.staff.person.nameWithTitle}
                                </p:column>
                                <p:column headerText="Department Name">
                                    #{ss.staff.department.name}
                                </p:column>
                                <p:column headerText="Staff Category">
                                    #{ss.staff.staffCategory.name}
                                </p:column>
                                <p:column headerText="Staff Designation">
                                    #{ss.staff.designation.name}
                                </p:column>
                                <p:column headerText="Staff Roster" >
                                    #{ss.staff.roster.name}
                                </p:column>  
                                <p:column headerText="Leave Type" >
                                    #{ss.leaveType}
                                </p:column>

                                <p:column headerText="Crated Date" >
                                    #{ss.createdAt}
                                </p:column>  
                                <p:column headerText="Leave Date" >
                                    #{ss.leaveDate}
                                </p:column>  
                                <p:column headerText="Leave Qty" >
                                    #{ss.qty}
                                </p:column> 
                                <p:column headerText="Comments" >
                                    #{ss.form.comments}
                                </p:column> 
                                 <f:facet name="footer">
                                    <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                    <p:outputLabel value="Print At : " />
                                    <p:outputLabel value="#{commonController.currentDateTime}" >
                                        <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                    </p:outputLabel>
                                 </f:facet>
                            </p:dataTable>
                        </p:panel>


                    </p:panel>

                </h:form>
            </ui:define>

        </ui:composition>

    </h:body>
</html>
